<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>StoreStaff</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
    <div class="banner">
        
        <h1>
            <span class="type">Class</span>
            StoreStaff
            
                <span class="parent">&lt;
                    
                    ActiveRecord::Base
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../files/app/models/store_staff_rb.html">app/models/store_staff.rb</a></li>
            
            <li><a href="../files/app/models/store_staff/staff_record_rb.html">app/models/store_staff/staff_record.rb</a></li>
            
            <li><a href="../files/app/models/store_staff/staff_salary_rb.html">app/models/store_staff/staff_salary.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  
    <!-- Namespace -->
    <div class="sectiontitle">Namespace</div>
    <ul>
      
        <li>
          <span class="type">MODULE</span>
          <a href="StoreStaff/StaffRecord.html">StoreStaff::StaffRecord</a>
        </li>
      
        <li>
          <span class="type">MODULE</span>
          <a href="StoreStaff/StaffSalary.html">StoreStaff::StaffSalary</a>
        </li>
      
    </ul>
  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>E</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-encrypt_with_salt">encrypt_with_salt</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>F</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-format_employeed_at">format_employeed_at</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>P</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-password_connection-3F">password_connection?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>R</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-reset_password-21">reset_password!</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>S</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-status_i18n">status_i18n</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>W</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="#method-i-work_year">work_year</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  
    <!-- Includes -->
    <div class="sectiontitle">Included Modules</div>
    <ul>
      
        <li>
          
            <a href="StatusObject.html">
              StatusObject
            </a>
          
        </li>
      
        <li>
          
            <a href="StoreStaff/StaffSalary.html">
              StoreStaff::StaffSalary
            </a>
          
        </li>
      
        <li>
          
            <a href="StoreStaff/StaffRecord.html">
              StoreStaff::StaffRecord
            </a>
          
        </li>
      
    </ul>
  



  

    

    

    
      <!-- Section constants -->
      <div class="sectiontitle">Constants</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class="attr-name">ONE_YEAR</td>
            <td>=</td>
            <td class="attr-value">1</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"></td>
            </tr>
          
        
      </table>
    


    
      <!-- Section attributes -->
      <div class="sectiontitle">Attributes</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>password</td>
            <td class='attr-desc'></td>
          </tr>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>password_confirmation</td>
            <td class='attr-desc'></td>
          </tr>
        
      </table>
    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-encrypt_with_salt">
            
              <b>encrypt_with_salt</b>(txt,salt)
            
            <a href="../classes/StoreStaff.html#method-i-encrypt_with_salt" name="method-i-encrypt_with_salt" class="permalink">Link</a>
          </div>

          
            <div class="description">
              
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-encrypt_with_salt_source')" id="l_method-i-encrypt_with_salt_source">show</a>
                
              </p>
              <div id="method-i-encrypt_with_salt_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/store_staff.rb, line 31</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">encrypt_with_salt</span>(<span class="ruby-identifier">txt</span>,<span class="ruby-identifier">salt</span>)
  <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA256</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-node">&quot;#{txt}#{salt}&quot;</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-format_employeed_at">
            
              <b>format_employeed_at</b>()
            
            <a href="../classes/StoreStaff.html#method-i-format_employeed_at" name="method-i-format_employeed_at" class="permalink">Link</a>
          </div>

          
            <div class="description">
              
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-format_employeed_at_source')" id="l_method-i-format_employeed_at_source">show</a>
                
              </p>
              <div id="method-i-format_employeed_at_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/store_staff.rb, line 48</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">format_employeed_at</span>
  <span class="ruby-identifier">employeed_at</span>.<span class="ruby-identifier">try</span>(<span class="ruby-value">:strftime</span>, <span class="ruby-string">&quot;%Y-%m-%d&quot;</span>) <span class="ruby-operator">||</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&quot;%Y-%m-%d&quot;</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-password_connection-3F">
            
              <b>password_connection?</b>()
            
            <a href="../classes/StoreStaff.html#method-i-password_connection-3F" name="method-i-password_connection-3F" class="permalink">Link</a>
          </div>

          
            <div class="description">
              
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-password_connection-3F_source')" id="l_method-i-password_connection-3F_source">show</a>
                
              </p>
              <div id="method-i-password_connection-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/store_staff.rb, line 35</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">password_connection?</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">encrypted_password</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">encrypt_with_salt</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">password</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">salt</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-reset_password-21">
            
              <b>reset_password!</b>(new_password, pass_confirmation)
            
            <a href="../classes/StoreStaff.html#method-i-reset_password-21" name="method-i-reset_password-21" class="permalink">Link</a>
          </div>

          
            <div class="description">
              
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-reset_password-21_source')" id="l_method-i-reset_password-21_source">show</a>
                
              </p>
              <div id="method-i-reset_password-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/store_staff.rb, line 39</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">reset_password!</span>(<span class="ruby-identifier">new_password</span>, <span class="ruby-identifier">pass_confirmation</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">new_password</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">pass_confirmation</span>
    <span class="ruby-keyword">return</span> <span class="ruby-constant">Status</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">success</span><span class="ruby-operator">:</span> <span class="ruby-keyword">false</span>, <span class="ruby-identifier">message</span><span class="ruby-operator">:</span> <span class="ruby-string">&#39;请确保密码的一致性!&#39;</span>)
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">reset_password</span>(<span class="ruby-identifier">new_password</span>, <span class="ruby-identifier">pass_confirmation</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">save!</span>
  <span class="ruby-constant">Status</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">success</span><span class="ruby-operator">:</span> <span class="ruby-keyword">true</span>, <span class="ruby-identifier">message</span><span class="ruby-operator">:</span> <span class="ruby-string">&#39;恭喜您重置密码成功!!&#39;</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-status_i18n">
            
              <b>status_i18n</b>()
            
            <a href="../classes/StoreStaff.html#method-i-status_i18n" name="method-i-status_i18n" class="permalink">Link</a>
          </div>

          
            <div class="description">
              
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-status_i18n_source')" id="l_method-i-status_i18n_source">show</a>
                
              </p>
              <div id="method-i-status_i18n_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/store_staff.rb, line 52</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">status_i18n</span>
  <span class="ruby-keyword">case</span> <span class="ruby-identifier">status</span>
  <span class="ruby-keyword">when</span> <span class="ruby-number">0</span> <span class="ruby-keyword">then</span> <span class="ruby-string">&#39;试用期&#39;</span>
  <span class="ruby-keyword">when</span> <span class="ruby-number">1</span> <span class="ruby-keyword">then</span> <span class="ruby-string">&#39;正式员工&#39;</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-work_year">
            
              <b>work_year</b>()
            
            <a href="../classes/StoreStaff.html#method-i-work_year" name="method-i-work_year" class="permalink">Link</a>
          </div>

          
            <div class="description">
              
            </div>
          

          

          

          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source:
                <a href="javascript:toggleSource('method-i-work_year_source')" id="l_method-i-work_year_source">show</a>
                
              </p>
              <div id="method-i-work_year_source" class="dyn-source">
                <pre><span class="ruby-comment"># File app/models/store_staff.rb, line 59</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">work_year</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">update!</span>(<span class="ruby-identifier">employeed_at</span><span class="ruby-operator">:</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>) <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-keyword">self</span>.<span class="ruby-identifier">employeed_at</span>.<span class="ruby-identifier">present?</span>
  <span class="ruby-ivar">@year</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">year</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">employeed_at</span>.<span class="ruby-identifier">year</span>
  <span class="ruby-keyword">if</span> <span class="ruby-ivar">@year</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-constant">ONE_YEAR</span>
    <span class="ruby-node">&quot;#{@year}年&quot;</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-ivar">@month</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">month</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">employeed_at</span>.<span class="ruby-identifier">month</span>
    <span class="ruby-ivar">@month</span> <span class="ruby-operator">&gt;</span> <span class="ruby-number">0</span> <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{@month}个月&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-number">0</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>
